i = 0
while i < 1000:
    i += 1
    cnt = i
    cot = 0
    while cnt != 0:
        cnt //= 10
        cot += 1
    cnt = i
    sum = 0
    while cnt != 0:
        temp = cnt % 10
        cnt //= 10
        sum = sum +  temp**cot
    if sum == i:
        print(i,end=" ")
